; Disassembly of the file "Rainbow - Ver 2 (198x)(Hanson)[From Proto EPROM].bin"
; aka "Ver. 2." - Originally by ?? Hanson (C) 198? (all in the file name, eh?)
; 
; CPU Type: Z80 for the Bally Professional Arcade system
; 
; Dis-assembly Created with dZ80 1.50 by Richard C. Degler
; 
; From Scratch on Wednesday, 02 of July 2008 at 03:20 PM
; 

        NOLIST
        INCLUDE "HVGLIB.H"

; ********************* Defines for Variables
RESET   EQU     $0000

CRAMP   EQU     $4F40         ; Color RAMP = 0, Even Colors
ILINE   EQU     $4F41         ; Interrupt LINE counter by 12
EMPTY   EQU     $4F42         ; Not used, should count seconds
SIXTY   EQU     $4F43         ; SIXTYths counter = 0 to 59
; Note: Incremented but never saved, blocking the colors from
; rolling around the screen and the seconds counter from ever
; counting up - also blocks a call to the STIMER System Routine
; once a second, which would count the game timer down to 0.
SPLIT   EQU     $4F44         ; Split Value

        LIST
        ORG     FIRSTC

; ********************* First Address in Cartridge
; L2000:
        DB      'U'		; $55 Menu Sentinal

        DW      MENUST		; System Menu Start Node
        DW      L2007		; Text String "RAINBOW"
        DW      L201B		; do RAINBOW Start

; ********************* "RAINBOW" text string
L2007:  DB      'R','A','I','N','B','O','W',$00

; ********************* "SPLIT VALUE" text string
L200F:  DB      'S','P','L','I','T',$20,'V','A','L','U','E',$00

; ********************* Do RAINBOW here
L201B:  SYSSUK  GETPAR        ; Use the title from MENU.
        DW      L200F         ; "Enter SPLIT VALUE" text
        DB      $81           ; 1 Digit, zero suppressed
        DW      SPLIT         ; ... and Store it here

        XOR     A
        OUT     (MAGIC),A     ; Clear Magic Register
        LD      A,$07
        OUT     (COL0L),A
        OUT     (COL0R),A     ; Set COLOR 0 to WHITE
        LD      A,$52
        OUT     (COL1L),A
        OUT     (COL1R),A     ; Set COLOR 1 to RED
        LD      HL,$0078
        LD      DE,$4000      ; Upper Left of Screen
        LD      L,$20         ; Loop Count to 32
        LD      A,$AA         ; Fill with Color 2
L203B:  LD      BC,$0078      ; Bytes to 3 x BYTEPL
        SYSTEM  FILL          ; Do Fill Area

        PUSH    HL            ; Store Loop Count
        LD      HL,$0078
        ADD     HL,DE         ; Move down to Next Block
        EX      DE,HL
        POP     HL            ; Restore Loop Count
        ADD     A,$55         ; Alternate $FF for Color 3
        CP      $54           ; ... is Not Rolled over ?
        JR      NZ,L204F                ; (+$02)
        LD      A,$AA         ; Else Back to Color 2
L204F:  DEC     L             ; Count Down and Loop
        JR      NZ,L203B                ; (-$17)
        LD      A,$04
        OUT     (XPAND),A     ; Set for Color 1 on Color 0
        SYSSUK  WRITP
        DB      $38           ; X = 56
        DB      $26           ; Y = 38
        DB      $08           ; Magic to Expand 
        DW      L20F4         ; BALLY Pattern

        XOR     A
        OUT     (XPAND),A     ; Set for Color 0 on Color 0
        SYSSUK  PAWS
        DB      $78           ; Wait 2 full seconds

        DI                    ; Set Interrupts
        XOR     A
        LD      (CRAMP),A
        LD      (SIXTY),A
        LD      (EMPTY),A     ; Initialize Variables
        LD      A,$16
        LD      (ILINE),A     ; Initial Interrupt LINE = 22
        OUT     (INLIN),A     ; Set Interrupt Line Register
        CALL    L2099         ; To Increment Colors 2 and 3
        LD      A,(SPLIT)     ; Read SPLIT Value
        ADD     A,A
        ADD     A,A
        OUT     (HORCB),A     ; Boundary to 4 x SPLIT
        LD      A,$20
        LD      I,A
        LD      A,$F2
        OUT     (INFBK),A     ; Interrupt Vector at L20F2
        LD      A,$08
        OUT     (INMOD),A     ; For Screen Interrupts only
        IM      2
        EI      
L208E:  SYSSUK  SENTRY        ; Loop Here until Keypress
        DW      ALKEYS        ; Keypad mask table

        CP      SKYD          ; Ignore NOT Key Down ?
        JR      NZ,L208E                ; (-$08)
        JP      RESET         ; To SYSTEM RESET

; ********************* Increment Colors 2 and 3 Routine
L2099:  LD      A,(CRAMP)     ; Read Color Ramp
        LD      C,A
        LD      B,$04
        LD      D,$08
        OUT     (COL2L),A     ; Color 2 Left = CRAMP
        ADD     A,D
        OUT     (COL3L),A     ; Color 3 Left = CRAMP + 8
        ADD     A,D
        LD      (CRAMP),A     ; Save Color Ramp + 16
        LD      A,C
        ADD     A,$04
        OUT     (COL2R),A     ; Color 2 Right = CRAMP + 4
        ADD     A,D
        OUT     (COL3R),A     ; Color 3 Right = CRAMP + 12
        RET     

; ********************* RAINBOW Interrupt Routine
L20B3:  PUSH    AF            ; Store Registers
        PUSH    BC
        PUSH    DE
        PUSH    HL
        CALL    L2099         ; To Increment Colors 2 and 3
        LD      A,$20
        LD      I,A
        LD      A,$F2
        OUT     (INFBK),A     ; Interrupt Vector at L20F2
        LD      A,(ILINE)
        ADD     A,$0C         ; Interrupt LINE counter + 12
        CP      $C0           ; is it still above Line 192 ?
        JR      C,L20E7                 ; (+$1c)
        LD      HL,SIXTY
        LD      A,(HL)        ; Read SIXTYths counter
        INC     A
        DAA                   ; Un-Hexadecimal it
        CP      $60           ; is it NOT equal 60 ?
        LD      A,(EMPTY)     ; Read Seconds Counter first
        JR      NZ,L20E2                ; (+$0a)
        LD      (HL),$00      ; Reset SIXTY to 0
        ADD     A,$08
        LD      (EMPTY),A     ; Save Seconds + 8 (once a second)
        CALL    STIMER        ; To STIMER System Routine
L20E2:  LD      (CRAMP),A     ; Save ?? as Color RAMP
        LD      A,$0A         ; Reset ILINE and INLIN to 10
L20E7:  LD      (ILINE),A     ; Save Interrupt LINE counter
        OUT     (INLIN),A     ; Set Interrupt Line Register
        POP     HL            ; Restore Registers
        POP     DE
        POP     BC
        POP     AF
        EI                    ; Enable Interrupts      
        RET     

; ********************* RAINBOW Interrupt Routine VECTOR
L20F2:  DW      L20B3         ; Jump to Interrupt Routine

; ********************* BALLY Pattern Data
L20F4:  DB      $06           ; W = 6 bytes (48 pixels)
        DB      $18           ; H = 24
        DB      $00,$00,$00,$00,$30,$00 ; ........ ........ ........ ........ ..XX.... ........
        DB      $00,$00,$00,$00,$78,$00 ; ........ ........ ........ ........ .XXXX... ........
        DB      $00,$07,$F0,$00,$D8,$00 ; ........ .....XXX XXXX.... ........ XX.XX... ........
        DB      $00,$18,$3C,$00,$D1,$00 ; ........ ...XX... ..XXXX.. ........ XX.X...X ........
        DB      $00,$60,$1C,$01,$92,$80 ; ........ .XX..... ...XXX.. .......X X..X..X. X.......
        DB      $01,$C1,$0E,$03,$26,$80 ; .......X XX.....X ....XXX. ......XX ..X..XX. X.......
        DB      $03,$06,$1C,$03,$26,$80 ; ......XX .....XX. ...XXX.. ......XX ..X..XX. X.......
        DB      $07,$0C,$1C,$03,$2D,$83 ; .....XXX ....XX.. ...XXX.. ......XX ..X.XX.X X.....XX
        DB      $0E,$0C,$3C,$06,$4D,$B3 ; ....XXX. ....XX.. ..XXXX.. .....XX. .X..XX.X X.XX..XX
        DB      $0C,$18,$78,$06,$59,$33 ; ....XX.. ...XX... .XXXX... .....XX. .X.XX..X ..XX..XX
        DB      $1C,$18,$E0,$06,$DB,$76 ; ...XXX.. ...XX... XXX..... .....XX. XX.XX.XX .XXX.XX.
        DB      $38,$39,$C3,$EC,$92,$66 ; ..XXX... ..XXX..X XX....XX XXX.XX.. X..X..X. .XX..XX.
        DB      $30,$32,$07,$0D,$34,$6E ; ..XX.... ..XX..X. .....XXX ....XX.X ..XX.X.. .XX.XXX.
        DB      $70,$37,$0E,$4D,$3C,$EE ; .XXX.... ..XX.XXX ....XXX. .X..XX.X ..XXXX.. XXX.XXX.
        DB      $60,$73,$8C,$CE,$38,$EC ; .XX..... .XXX..XX X...XX.. XX..XXX. ..XXX... XXX.XX..
        DB      $60,$71,$DC,$CC,$21,$FC ; .XX..... .XXX...X XX.XXX.. XX..XX.. ..X....X XXXXXX..
        DB      $E0,$60,$D9,$CC,$3E,$DC ; XXX..... .XX..... XX.XX..X XX..XX.. ..XXXXX. XX.XXX..
        DB      $C0,$E1,$D9,$97,$DC,$18 ; XX...... XXX....X XX.XX..X X..X.XXX XX.XXX.. ...XX...
        DB      $C0,$E1,$9B,$F7,$00,$18 ; XX...... XXX....X X..XX.XX XXXX.XXX ........ ...XX...
        DB      $C0,$DB,$8E,$E0,$00,$18 ; XX...... XX.XX.XX X...XXX. XXX..... ........ ...XX...
        DB      $C1,$DF,$00,$00,$00,$30 ; XX.....X XX.XXXXX ........ ........ ........ ..XX....
        DB      $C1,$80,$00,$00,$00,$30 ; XX.....X X....... ........ ........ ........ ..XX....
        DB      $63,$00,$00,$00,$00,$30 ; .XX...XX ........ ........ ........ ........ ..XX....
        DB      $3E,$00,$00,$00,$00,$00 ; ..XXXXX. ........ ........ ........ ........ ........

; ********************* End of Z80 Source Code
; L2186:   122 bytes filler to match source ROM
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF,$FF,$FF,$FF,$FF,$FF,$FF
        DB      $FF,$FF

; L2200:
        DEFS    $600    ; 1536 NOP'd zero bytes

				; $27FF = End of Code
